package com.owg.jigsaw.javafx.fxml;

import java.util.Collection;

import com.owg.jigsaw.WBlock;
import com.owg.jigsaw.WPalette;
import com.owg.jigsaw.WPane;
import com.owg.jigsaw.WRoot;

import javafx.geometry.Insets;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;

public class FXPalette extends VBox implements WPaneSpawner
{	
	private WPalette model;
	
	public FXPalette()
	{
		super(24);
		setBackground(new Background(new BackgroundFill(Color.DARKGRAY, CornerRadii.EMPTY, Insets.EMPTY)));
	}

	@Override
	public WPane getWPane(WRoot root)
	{
		if(model == null)
			model = new WPalette(root, null, this);
		return model;
	}

	public void setPalette(WRoot root, Collection<WBlock> paletteBlocks)
	{
		if(model == null)
			getWPane(root);
		model.setPalette(paletteBlocks);
	}
}
